package bytestream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class FileInputStreamDemo {
    public static void main(String[] args) {
        InputStream inputStream=null;
        try {
            inputStream=new FileInputStream("a.txt");
//            int i;
//
//            while ((i=inputStream.read())!=-1)
//                System.out.print((char)i);
            byte[] bytes=new byte[1024];
            int n=inputStream.read(bytes,0,3);
            System.out.println(new String(bytes,0,n));


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream!=null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
